|
|
|
|
|
|
|
To invoke the Print dialog box, just call the CommonDialog control's ShowPrinter method. There are no required flags to set prior to the call. |
|
|
|
|
|
|
|
|
After the Print dialog box is displayed, the user can select the printer from the Name list at the top of the dialog box. This list contains all the printers installed in the user's operating system. Just below the Name list is the Status line, which tells you the current status of the selected printer. |
|
|
|
|
|
|
|
|
If a user wants to change any printer-specific parameters (such as paper size and margins), he or she can click the Properties button on the Print dialog box. This action brings up the Properties dialog box for the selected printer, as shown in Figure 7.10. This dialog box lets the user control all the settings of the printer, just as with the Windows Control Panel. |
|
|
|
|
|
|
|
|
Figure 7.10
The Properties dialog box for the printer lets you
control paper size, margins, and other printer attributes. |
|
|
|
|
|
|
|
|
The Print dialog box returns the information provided by the user in the dialog box's properties. The FromPage and ToPage properties tell you the starting and ending pages of the printout as selected by the user. The Copies property tells you how many copies the user wants printed. These details are provided only as information. The Print dialog box does not automatically create the desired printout. |
|
|
|
|
|
|
|
|
To see how the Printer dialog box works, replace the code in the test project's cmdTest_Click event procedure with the following: |
|
|
|
|
|
|
|
|
cdlTest.Flags = cdlPDDisablePrintToFile
cdlTest.Copies = 3
cdlTest.PrinterDefault = True
cdlTest.ShowPrinter
MsgBox "The default printer is:" & Printer.DeviceName |
|
|
|
|
|
|
|
|
In this sample code, properties and flags are used to disable the Print to File option and set the default number of copies to 3. In addition, the PrinterDefault property means that the dialog box will use the control's properties to modify the default system printer. The Printer dialog box has quite a few useful options that are detailed in the Visual Basic help system. |
|
|
|
|
|